package com.guoxin.part1.chapter2;

/**
 * @author guoxin
 * @date 2019/8/26
 */
public class ThreadConstruction {
    public static void main(String[] args) {
        Thread t1 = new Thread("t1");
        ThreadGroup group = new ThreadGroup("TestGroup");
        Thread t2 = new Thread(group, "t2");
        ThreadGroup mainThreadGruop = Thread.currentThread().getThreadGroup();
        System.out.println("Main thread belong group: " + mainThreadGruop.getName());
        System.out.println("t1 and main belong the same gruop: " + (mainThreadGruop == t1.getThreadGroup()));
        System.out.println("t2 thread group net belong main gruop: " + (mainThreadGruop == t2.getThreadGroup()));
        System.out.println("t2 thread group belong main TestGroup: " + (group == t2.getThreadGroup()));

    }
}
